#ifndef __12864_H
#define	__12864_H

#include "stm32f10x.h"
#include "bsp_sysTick.h" 

//为 1 则使用硬件时序，为 0 使用软件时序
#define  USE_SPI_MOD   0

#if  USE_SPI_MOD==1
//硬件时序
#define   LCD12864_USE_SPI      SPI2
#define   LCD12864_USE_SPI_CLK  RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE)

#define   LCD12864_PORT_CLK  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
#define   LCD12864_PORT      GPIOB
#define   LCD12864_CLK_PIN   GPIO_Pin_13 //LCD的引脚E
#define   LCD12864_DA_PIN    GPIO_Pin_15 //LCD的引脚R/W
#define   LCD12864_CS_PIN    GPIO_Pin_12 //LCD的引脚RS

//片选，LCD的引脚RS
#define lcd_cs      PBout(12)
#else 
//模拟时序
#define   LCD12864_PORT_CLK  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE);
#define   LCD12864_PORT      GPIOB
#define   LCD12864_CLK_PIN   GPIO_Pin_7 //LCD的引脚E
#define   LCD12864_DA_PIN    GPIO_Pin_8 //LCD的引脚R/W
#define   LCD12864_CS_PIN    GPIO_Pin_9 //LCD的引脚RS

//定义引脚位段宏
//时钟，LCD的引脚E
#define lcd_clk     PBout(7)
//数据，LCD的引脚R/W 
#define lcd_data    PBout(8)
//片选，LCD的引脚RS
#define lcd_cs      PBout(9)

#endif
//function
void LCD_inital(void);

uint8_t LCD_set_position(u8 x, u8 y);

void send_data(u8 ch);

void send_cmd(u8 com);

void display_string(char *p,u8 x, u8 y);

void clean_dram(void);

void clean_dram_line(u8 y);
	
void clean_gran(void);

void write_gram(const unsigned char *p);

void write_gram_one_line(uint8_t xstart,uint8_t xlen,uint8_t y,uint8_t data);
#endif
